<?php include $this->templateDir .'common/header.php';?>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space10">
    <blockquote class="layui-elem-quote">
        <p> 注意事项： </p>
        <p> 1.邮件发送模式支持SMTP/mail/sendmail三种模式，推荐SMTP</p>
        <p> 2.注意看清楚是否使用SSL/TLS</p>
        <p> 3.端口号参考：SSL协议下一般为465/587,非SSL协议下一般为25;当然最好根据邮件服务商的说明来进行配置</p>
    </blockquote>
    <form  method="post" class="layui-form layui-form-pane">
        <div class="layui-form-item">
            <label for="sendmail" class="layui-form-label">发件人邮箱</label>
            <div class="layui-input-inline">
                <input type="text" id="sender_mail" name="sender_mail" autocomplete="off" lay-verify="required|email" value="" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">这个是用来显示发件人邮箱地址的</div>
        </div>
        <div class="layui-form-item">
            <label for="sendname" class="layui-form-label">发件人昵称</label>
            <div class="layui-input-inline">
                <input type="text" id="sender_name" name="sender_name" autocomplete="off" lay-verify="required" value="" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">这个是用来显示发件人昵称</div>
        </div>
        <div class="layui-form-item">
            <label for="protocol" class="layui-form-label">邮件协议</label>
            <div class="layui-input-inline">
                <select name="protocol" lay-filter="protocol" id="protocol">
                    <option value="smtp">smtp</option>
                    <option value="mail">mail</option>
                    <option value="sendmail">sendmail</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="host" class="layui-form-label">服务器地址</label>
            <div class="layui-input-inline">
                <input type="text" id="host" name="host" autocomplete="off" lay-verify="" value="smtp.exmail.qq.com" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">smtp.exmail.qq.com是QQ企业邮箱smtp地址</div>
        </div>
        <div class="layui-form-item">
            <label for="mailaddress" class="layui-form-label">邮箱账号</label>
            <div class="layui-input-inline">
                <input type="text" id="mail_address" name="mail_address" lay-verify="" autocomplete="off" value="" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">邮箱账号，一般是邮箱格式，也可能是非邮箱格式</div>
        </div>
        <div class="layui-form-item">
            <label for="mailpassword" class="layui-form-label">邮箱密码</label>
            <div class="layui-input-inline">
                <input type="text" id="mail_password" name="mail_password" lay-verify="" autocomplete="off" value="" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">这个是SMTP邮箱密码，也可能是授权码</div>
        </div>
        <div class="layui-form-item">
            <label for="smtp_crypto" class="layui-form-label">加密方式</label>
            <div class="layui-input-inline">
                <select name="smtp_crypto">
                    <option value="0" selected="">不加密</option>
                    <option value="1" >SSL</option>
                    <option value="2" >TLS</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="port" class="layui-form-label">端口号</label>
            <div class="layui-input-inline">
                <input type="text" id="port" name="port" autocomplete="off" lay-verify="required" value="" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item"   pane style="width: 310px;">
            <label class="layui-form-label">是否激活</label>
            <div class="layui-input-block" >
                <input type="radio" name="isactive" value="1" title="激活" checked>
                <input type="radio" name="isactive" value="0" title="不激活" >
            </div>
        </div>
        <div class="layui-form-item">
            <button class="layui-btn" key="set-mine" lay-filter="addEmailButton" lay-submit>确认新增</button>
        </div>
    </form>
</div>
</div>
<script type="text/javascript">
    layui.use(['form', 'layer','jquery'], function(){
        var form = layui.form,
            $ = layui.jquery,
            layer = layui.layer ;

        //添加角色操作
        form.on('submit(addEmailButton)', function(data){
            var url = '<?php echo u("email","add");?>';
             $.ajax({
                 url:url
                 ,type:"post"
                 ,dataType:"json"
                 ,data:data.field
                 ,success:function (res ) {
                    if(res.status == "ok"){
                        layer.msg(  res.data,{icon:6,time:1000} );
                        setTimeout(function(){parent.window.location.reload();},1000);
                    }else{
                        layer.msg(res.data);
                    }

                 }
             });
            return false;
        });
    });
</script>
</body>
</html>